﻿@using Models.DTO
@model Models.ViewModel.IndexPageViewModel
<div class="col-md-9 box-left">
    <div class="wrapper-content  animated fadeIn blog">
        @if(Model.Posts.Any()) {
            <div class="orderby">
                <div class="row">
                    <div class="col-md-9 text-center">
                        @{ Html.RenderPartial("_Pagination"); }
                    </div>
                    <div class="col-md-3">
                        <div class="btn-group pull-right">
                            <a class="btn btn-info" href="/dashboard#/writeblog" target="_blank">
                                <i class="icon icon-pencil"></i>
                                写文章
                            </a>
                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                排序方式<span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu">
                                <li>
                                    <a href="@Request.Url.AbsolutePath">最后修改日期</a>
                                </li>
                                <li>
                                    <a href="@Request.Url.AbsolutePath?orderby=0">最后发表日期</a>
                                </li>
                                <li role="separator" class="divider"></li>
                                <li>
                                    <a href="@Request.Url.AbsolutePath?orderby=3">评论最多</a>
                                </li>
                                <li>
                                    <a href="@Request.Url.AbsolutePath?orderby=2">访问量最多</a>
                                </li>
                                <li>
                                    <a href="@Request.Url.AbsolutePath?orderby=4">支持最多</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

            foreach(PostOutputDto post in Model.Posts) {
                Html.RenderPartial("_ArticleListItem_Admin", post);
            }
        } else {
            List<PostOutputDto> list = Model.PostsQueryable.OrderBy(p => Guid.NewGuid()).Skip(0).Take(5).ToList();
            if(list.Any()) {
                <div class="page-header">
                    <h3>Oops！抱歉~没有找到相关的文章或资源！如果您有相关的结果，您可以 @Html.ActionLink("点击这里", "Publish", "Post", null, new {@class = "btn btn-info btn-lg"}) 投稿哦！以下是一些随机推荐：</h3>
                </div>
                foreach(PostOutputDto post in list) {
                    Html.RenderPartial("_ArticleListItem_Admin", post);
                }
            }
        }
        <div class="col-md-12 text-center">
            @{ Html.RenderPartial("_Pagination"); }
        </div>
    </div>
</div>